import request from '@/utils/request'

const api = {
  userLoginUrl: '/auth/user_login',
  getUserPageUrl: '/comdesk_user/get_user_page',
  addUserUrl: '/comdesk_user/add_user',
  updateUserUrl: '/comdesk_user/update_user',
  deleteUserUrl: '/comdesk_user/delete_user',
  resetUserPasswordUrl: '/comdesk_user/reset_user_password',
  changeUserRoleUrl: '/comdesk_user/change_user_role',
}

export async function userLoginApi(params: { [key: string]: string }) {
  const res = await request({
    url: api.userLoginUrl,
    method: 'post',
    data: params,
  })
  return res
}

export async function getUserPageApi(params: { [key: string]: string }) {
  const res = await request({
    url: api.getUserPageUrl,
    method: 'post',
    data: params,
  })
  return res
}

export async function addUserApi(params: { [key: string]: string }) {
  const res = await request({
    url: api.addUserUrl,
    method: 'post',
    data: params,
  })
  return res
}

export async function updateUserApi(params: { [key: string]: string }) {
  const res = await request({
    url: api.updateUserUrl,
    method: 'post',
    data: params,
  })
  return res
}

export async function deleteUserApi(params: { [key: string]: string }) {
  const res = await request({
    url: api.deleteUserUrl,
    method: 'get',
    params: params,
  })
  return res
}

export async function resetUserPasswordApi(params: { [key: string]: string }) {
  const res = await request({
    url: api.resetUserPasswordUrl,
    method: 'get',
    params: params,
  })
  return res
}

export async function changeUserRoleApi(params: { [key: string]: string }) {
  const res = await request({
    url: api.changeUserRoleUrl,
    method: 'post',
    data: params,
  })
  return res
}
